var data=[]

self.onmessage=function(event){
    const {port,message}=event.data;
    console.log("线程A收到：",message);

    port.onmessage=function(e){
        console.log("workerA收到来自WorkerB的消息：",e.data);
        if(e.data.type=="pong"){
            // fetch("https://movie.douban.com/j/search_subjects?type=tv&tag=%E7%83%AD%E9%97%A8&page_limit=50&page_start=0").then(res=>{
            //     data=res.subjects
            //     port.postMessage({type:"ping",message:"Hello from Worker B!",date:new Date(),data:data})
            // })

            setTimeout(()=>{
                port.postMessage({type:"ping",message:"Hello from Worker B!",date:new Date()})
            },1500)
        }
    }
    port.postMessage({type:"ping",message:"Hello from Worker A!"});
}